<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地图导航</title>
    <style>
        * {
          margin: 0;
          padding: 0;
        }
        #container {
          width: 100%;
          height: 100vh;
          background-color: pink;
        }
      </style>
</head>
<body>
    <div id="container"></div>
    <script type="text/javascript">
        window._AMapSecurityConfig = {
          securityJsCode: "62c389a22483c4858ac8b63a3d3b16fc",
        };
      </script>
      <script src="https://webapi.amap.com/loader.js"></script>
    <script type="text/javascript"
            src="https://webapi.amap.com/maps?v=1.4.15&key=cae13acb723cb926ce1f0348a025e516"></script>
      <script type="text/javascript">
        var map = new AMap.Map("container", {
            zoom: 17,
            center:[121.472644, 31.231706]
        })

          function getLocation(lon, lat) {
            //window.swift.alert(lon + " " + lat)
            map.setZoomAndCenter(17,[lon,lat],true)

            //提供4个位置
            map.plugin(["AMap.PlaceSearch"], function () {
                const placeSearch = new AMap.PlaceSearch({
                    pageSize: 4 , //单页显示结果条数
                    pageIndex: 1, //页码
                    extensions: "base"
                });
                AMap.event.addListener(placeSearch, "complete", (result)=> {
                    window.swift.receiveData(JSON.stringify(result?.poiList?.pois || []));
                });
                placeSearch.searchNearBy("写字楼", new AMap.LngLat(lon,lat)); //使用插件搜索关键字并查看结果
            });
          }

          window.onload = function() {
            if(window.swift) {
                window.swift.getLocation()
            }
          }

      </script>
</body>
</html>